﻿using System;
using System.Windows.Forms;
using ProxyTool.Models;
using ProxyTool.Setting;
using ProxyTool.Utils;

namespace ProxyTool.Forms
{
    public partial class CreateProxyForm : Form
    {
        public CreateProxyForm()
        {
            InitializeComponent();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(this.txtName.Text))
                {
                    this.txtName.Focus();
                    throw new ProxyToolException("名称不能为空");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "创建异常");
                this.DialogResult = DialogResult.None;
            }
        }

        /// <summary>
        ///     获取名称
        /// </summary>
        /// <returns></returns>
        public string GetName()
        {
            return this.txtName.Text;
        }

        /// <summary>
        ///     获取ProxyType
        /// </summary>
        /// <returns></returns>
        public string GetProxyType()
        {
            return this.txtProxyType.Text;
        }

        /// <summary>
        ///     获取UseDataContract
        /// </summary>
        /// <returns></returns>
        public bool GetUseDataContract()
        {
            return this.chkUseDataContract.Checked;
        }
    }
}